#include <stdio.h>
#include <math.h>

void main()
{
	int count1 = 0,count2=0,n = 0, m = 0, Pow = 0, num = 0, j = 0, i = 0;

	for (i = 0; i <= 100000; i++)
	{
		//		n=i%10;
		Pow = 0;
		for (count2 = count1; count2 != 0;)
		{
			count2 /= 10;
			Pow++;
		}

		for (j = i; j != 0;)
		{
			n = j % 10;
			m = pow(n, Pow);
			num += m;
			j /=10;

		}
		if (num == i)
			printf("%d \n", num);

		num = 0;
		count1++;

	}

}
